package com.yunqiao.admin.modules.api.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yunqiao.service.api.entity.EvaluateEntity;
import com.yunqiao.service.api.EvaluateService;
import com.yunqiao.common.utils.PageUtils;
import com.yunqiao.common.utils.R;


/**
 * 文章表
 *
 * @author Crocutax
 * @email wangxw725@163.com
 * @date 2019-03-02 15:03:56
 */
@RestController
@RequestMapping("api/evaluate")
public class EvaluateController {

    @Autowired
    private EvaluateService evaluateService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("api:evaluate:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = evaluateService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("api:evaluate:info")
    public R info(@PathVariable("id") Integer id){
        EvaluateEntity evaluate = evaluateService.details(id);
        return R.ok().put("evaluate", evaluate);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("api:evaluate:save")
    public R save(@RequestBody EvaluateEntity evaluate){
        evaluateService.save(evaluate);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("api:evaluate:update")
    public R update(@RequestBody EvaluateEntity evaluate){
        evaluateService.updateById(evaluate);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("api:evaluate:delete")
    public R delete(@RequestBody Integer[] ids){
        evaluateService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
